All Questions
Tagged with text-processingshell
383 questions
1vote
2answers
87views
Filter for arbitrary AND patterns [duplicate]
Consider a command which takes arguments like this: cmd foo bar baz [arbitrary args...]. How do you build a filter of AND patterns based on those arguments? Something like this pipeline of greps: grep ...
8votes
5answers
1kviews
Run command on each line of CSV file, using fields in different places of the command
I have a CSV file and want to run a command for each line, using the fields of the file as separate arguments. For example given the following file: foo,42,red bar,13,blue baz,27,green I want to run ...
0votes
2answers
92views
Run program only on matching lines
Let's say I have a program blackbox, and a file with the following contents: in this file this line contains =TAG= so does =TAG= this one as =TAG= does this other line this line does ...
0votes
3answers
102views
Splitting Words into space separated characters [duplicate]
I have a table with one word in each row. I want to split the word into space separated c h a r a c t e r s. Is there a way to do that via bash command? If yes, I also have a table with multiple words ...
0votes
2answers
280views
From hexdump to ascii (xxd -r stuck writing zero bytes)
To diagnose secure boot issues, I'm looking at the sbat sections of all bootloaders on a machine: sudo sh -c 'for f in /boot/efi/EFI/*/*.efi; do echo "$f"; objdump -j .sbat -s "$f" ...
0votes
5answers
126views
How can I replace the last occurrence of " before ] (text-manipulation)
I'm doing some text manipulation and I want to replace the last occurrence of " (with ", "four") before ] which could be in different lines. (this essentially adds a new item in ...
-2votes
1answer
182views
Error in command su
I am creating a command that will change a certain line in the /etc/profile file from a script, however in certain versions of Linux the sudo command may not be activated so it would be necessary to ...
3votes
5answers
478views
How to create a new column and add a random identifier to it with miller
I want to add a column with a randomly created "case number" to my csv file. The first 2 letters of the casenumber must be any letter from A-Z in capitals. followed by 5 random numbers. ...
25votes
3answers
5kviews
Is it now safe to parse the output of GNU ls?
The accepted wisdom for the past few decades has been that it is never a good idea to parse the output of ls ([1],[2]). For example, if I want to save a file's modification date along with its name ...
0votes
1answer
310views
Auto-translation of newline characters in the terminal
I'm following along here. I notice (this is not complete, just for demonstration) that at this point: #include <termios.h> raw.c_iflag &= ~(ICRNL | IXON); raw.c_oflag &= ~(OPOST); ...
6votes
2answers
1kviews
Why xargs does not process the last argument?
Observe: mark@L-R910LPKW:~$ echo a b | xargs -d' ' -I{} bash -c 'echo {} 1' a 1 b bash: line 2: 1: command not found mark@L-R910LPKW:~$ What is going on?
-2votes
1answer
59views
Split/extract street name from street number [duplicate]
I have some addresses.csv in this formats Street 1 Street 10 Street 100 Street 1000 Straße 1b Straße1b Street 1 B Street, 1B The Street 1B The-Street 1B The'Street 1B The&Street 1B The Str. 1B ...
2votes
2answers
122views
Create new file per line from txt file, avoid file name too long
I'm creating new file for every line of text in a .txt file file=/tmp/textFile.txt while IFS= read -r line do printf "%s\n" "$line" > /tmp/"$line"txt done < ...
0votes
0answers
28views
Find and replace text using sed using variable [duplicate]
I have a specific text: ==4 to be replaced by ==5. So, I initialized two variables with $i and $j with 4 and 5 respectively and used this sed command to do the work: sed -i 's/==${i}/==${j}/g' "...
0votes
3answers
819views
How can I store all the lines emitted by while loop in a single varianle in shell?
As far as I know, while loops in shell are executed in a sub-shell, so they cannot modify variables outside the loop. I'm writing a shell script and I want to store all the internal IPs of my machine ...